package com.czxy.tanhua.dubbo.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author 爱吃豆的土豆、
 * @Date 2023/3/31 8:26
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //填充创建时间
        setFieldValByName("created",new Date(),metaObject);
        //修改时间
        setFieldValByName("updated",new Date(),metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        //修改时间
        setFieldValByName("updated",new Date(),metaObject);
    }
}
